package com.test.spring.fusion.service.impl;

import java.util.Date;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.test.spring.fusion.domain.Consumers;
import com.test.spring.fusion.feign.FeignClientService;
import com.test.spring.fusion.mapper.ConsumersMapper;
import com.test.spring.fusion.service.ConsumersService;

import io.seata.spring.annotation.GlobalTransactional;

@Service
public class ConsumersServiceImpl extends ServiceImpl<ConsumersMapper, Consumers> implements ConsumersService {

	@Autowired
	private FeignClientService feignClientService;
	
	@GlobalTransactional(name="saveConsumers",rollbackFor = Exception.class)
	public void saveConsumers() {
		Consumers consumers = new Consumers();
		consumers.setId(new Date().getTime());
		consumers.setUsername(UUID.randomUUID().toString());
		this.save(consumers);
		feignClientService.saveProducers();
		System.out.println(10/0);
	}
	
}
